<?php


namespace App\Server;


use Qiniu\Auth;
use Qiniu\Storage\UploadManager;

class QiniuService
{
    public static function qiniu($file)
    {
        $uploadMgr = new UploadManager();
        $auth = new Auth("4VyY6DOQnePNgFWKNtY5jNovq0aVz9mZR3IAmgpL", "AMg0vgVPcbQyDbSzCxmriOgFcyUyhW1q6bATJiRT");
        $token = $auth->uploadToken("shixunhealthcare");
//        dd($auth);
        list($ret, $error) = $uploadMgr->putFile($token, $file,$file);
        if (isset($error)){
            return response()->json(['code'=>1001,'message'=>'error']);
        }

        return "http://rwjm2jnd8.hn-bkt.clouddn.com".'/'.$ret['key'];

    }
}
